package com.sdau.zhang.dao;

import com.sdau.zhang.vo.Luntan;
import com.sdau.zhang.vo.Response;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface LuntanDao {

    @Insert("insert into luntan(tid,content,userid,zan,zanguo,ptime) values(#{tid},#{content},#{userid},0,0,Now())")
    public int insertLuntan(Luntan luntan);

    @Delete("delete from luntan where tid=#{tid} and floor=#{fid}")
    public int deleteLuntan(int tid,int fid);

    /*@Update("update")
    public void updateT(Luntan luntan);*/

    @Select("select content from luntan where tid = #{tid} and floor = 1")
    public String getTopic(int tid);

    @Select("select * from luntan where tid = #{tid} order by floor ASC  limit #{begin},10")//每页取10楼
    public List<Luntan> getByTid(@Param("tid")int tid,@Param("begin") int begin,@Param("limitCount")int limitCount);



    @Insert("insert into response(tid,floor,rid,userid1,userid2,content) values(#{tid},#{floor},#{rid},#{userid1},#{userid2},#{content})")
    public int insertResponse(Luntan luntan);

    @Delete("delete from response where tid=#{tid} and floor=#{fid}")
    public int deleteResponse(int tid,int fid);

    @Select("select * from response where tid = #{tid} order by floor,rid ASC limit #{page},10")//每页取十楼
    public List<Response> getAllResponse(@Param("tid") int tid, @Param("page") int page);
}
